<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>总课程表</title>

    <!--data table-->
    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/js/data-tables/DT_bootstrap.css"/>

    <link href="${pageContext.request.contextPath}/static/css/style.css" rel="stylesheet">
    <link href="${pageContext.request.contextPath}/static/css/style-responsive.css" rel="stylesheet">

    <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
    <script src="${pageContext.request.contextPath}/static/js/html5shiv.js"></script>
    <script src="${pageContext.request.contextPath}/static/js/respond.min.js"></script>
    <![endif]-->
</head>

<body class="sticky-header" style="background: #e4e7ea">

<section>
    <!--body wrapper start-->
    <div class="wrapper">
        <div class="row">
            <div class="col-sm-12">
                <section class="panel">
                    <header class="panel-heading">
                        当前日期：<label id="title"></label>
                        <span class="tools pull-right">
                            <a href="javascript:;" class="fa fa-chevron-down"></a>
                            <a href="javascript:;" class="fa fa-times"></a>
                        </span>
                    </header>
                    <div class="panel-body">
                        <table class="table table-striped">
                            <thead>
                            <tr>
                                <th>#</th>
                                <th>班级</th>
                                <th>课程</th>
                                <th>教师</th>
                                <th>教室</th>
                            </tr>
                            </thead>
                            <tbody id="formBody">

                            </tbody>
                        </table>
                    </div>
                </section>
            </div>
        </div>
        <!--body wrapper end-->
    </div>
</section>

<!-- Placed js at the end of the document so the pages load faster -->
<script src="${pageContext.request.contextPath}/static/js/jquery-1.10.2.min.js"></script>
<script src="${pageContext.request.contextPath}/static/js/jquery-ui-1.9.2.custom.min.js"></script>
<script src="${pageContext.request.contextPath}/static/js/jquery-migrate-1.2.1.min.js"></script>
<script src="${pageContext.request.contextPath}/static/js/bootstrap.min.js"></script>
<script src="${pageContext.request.contextPath}/static/js/modernizr.min.js"></script>
<script src="${pageContext.request.contextPath}/static/js/jquery.nicescroll.js"></script>

<!--data table-->
<script type="text/javascript"
        src="${pageContext.request.contextPath}/static/js/data-tables/jquery.dataTables.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/static/js/data-tables/DT_bootstrap.js"></script>

<!--common scripts for all pages-->
<script src="${pageContext.request.contextPath}/static/js/scripts.js"></script>

<!--script for editable table-->
<script src="${pageContext.request.contextPath}/static/js/editable-table.js"></script>

<!-- END JAVASCRIPTS -->
<script>
    jQuery(document).ready(function () {
        EditableTable.init();
    });

    Date.prototype.toLocaleString = function () {
        function addZero(num) {
            if (num < 10)
                return "0" + num;
            return num;
        }

        // 按自定义拼接格式返回
        if (this.getFullYear() == 1970 && this.getMonth() == 0 && this.getDate() == 1) return null;
        return this.getFullYear() + "/" + addZero(this.getMonth() + 1) + "/" + addZero(this.getDate());
    };

    $(function () {
        let date = new Date();
        let dateYear = date.getFullYear();
        let dateMonth = date.getMonth() + 1;
        let dateDate = date.getDate();
        let dateDay = date.getDay();
        var week;
        switch (dateDay){
            case 1: week="星期一"; break;
            case 2: week="星期二"; break;
            case 3: week="星期三"; break;
            case 4: week="星期四"; break;
            case 5: week="星期五"; break;
            case 6: week="星期六"; break;
            default: week="星期天";
        }
        $("#title").html(dateYear + "年" + dateMonth + "月" + dateDate + "日" + "  " + week);

        $.ajax({
            url: "${pageContext.request.contextPath}/teachingInformation/getOneByClassName2",
            type: 'post',
            dataType: 'json',
            success: function (result) {
                if (result.code == 0) {
                    for (i = 0; i < result.lists.length; i++) {
                        showList(result.lists[i]);
                    }
                }
            },
            error: function (err) {
                alert(err.message);
            }
        })
    })

    var k = 0;
    function showList(userList) {
        var html = '';
        //遍历userList数组
        for (var i = 0; i < userList.length; i++) {
            k++;
            //拿到一个用户信息
            var item = userList[i];
            html += "<tr>";
            html += "<td>" + k + "</td>";
            html += "<td>" + item.classname + "</td>";
            html += "<td>" + item.subjectname + "</td>";
            html += "<td>" + item.teachername + "</td>";
            html += "<td>" + item.classroomname + "</td>";
            html += "</tr>";
        }
        $("#formBody").append(html);
    }
</script>

</body>
</html>

